memshr: Must be built on ia64 as well as x86, as blktap depends on it.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 28 Dec 2009 10:55:50 +0000 (10:55 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 28 Dec 2009 10:55:50 +0000 (10:55 +0000)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/Makefile
tools/Rules.mk
tools/memshr/bidir-hash.c

index d5cffa292382deb1dadc574cda70959961912575..388a925d3684107a909d0712112026520ce6997a 100644 (file)
@@ -21,6 +21,7 @@ SUBDIRS-$(VTPM_TOOLS) += vtpm_manager
 SUBDIRS-$(VTPM_TOOLS) += vtpm
 SUBDIRS-y += xenstat
 SUBDIRS-$(CONFIG_Linux) += libaio
+SUBDIRS-$(CONFIG_Linux) += memshr 
 SUBDIRS-$(CONFIG_Linux) += blktap
 SUBDIRS-$(CONFIG_Linux) += blktap2
 SUBDIRS-$(CONFIG_NetBSD) += libaio
@@ -34,9 +35,7 @@ SUBDIRS-$(CONFIG_IOEMU) += ioemu-dir
 SUBDIRS-y += xenpmd
 SUBDIRS-y += libxl
 SUBDIRS-y += remus
-
-SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += memshr 
-SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += xenpaging
+SUBDIRS-$(CONFIG_X86) += xenpaging
 
 # These don't cross-compile
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
index 83899d3cbd734c71ee50ecf10a371f2c7b6739d0..53d8aa86ce19479d0ef572b58f1eb861ef7ae9d9 100644 (file)
@@ -64,7 +64,7 @@ INSTALL_PYTHON_PROG = \
        $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
 
 subdirs-all subdirs-clean subdirs-install: .phony
-       @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y) $(SUBDIRS-yy); do \
+       @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
                $(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
        done
 
index e3e0e15831dd52b22fab37dbd179763c4022aa90..6c0dc3d92d4fd829370f98767527e9b1c0db7474 100644 (file)
@@ -100,21 +100,31 @@ int            __hash_iterator(struct __hash *h,
                         void *d);
 static void      hash_resize(struct __hash *h);
 
-static inline void atomic_add(uint32_t *v, uint32_t i)
+#if defined(__ia64__)
+#define ia64_fetchadd4_rel(p, inc) do {                         \
+    uint64_t ia64_intri_res;                                    \
+    asm volatile ("fetchadd4.rel %0=[%1],%2"                    \
+                : "=r"(ia64_intri_res) : "r"(p), "i" (inc)      \
+                : "memory");                                    \
+} while (0)
+static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); }
+static inline void atomic_dec(uint32_t *v) { ia64_fetchadd4_rel(v, -1); }
+#else /* __x86__ */
+static inline void atomic_inc(uint32_t *v)
 {
-    asm volatile(
-        "lock ; addl %1,%0"
-        :"=m" (*(volatile uint32_t *)v)
-        :"ir" (i), "m" (*(volatile uint32_t *)v) );
+    asm volatile (
+        "lock ; incl %0"
+        : "=m" (*(volatile uint32_t *)v)
+        : "m" (*(volatile uint32_t *)v) );
 }
-
-static inline void atomic_sub(uint32_t *v, uint32_t i)
+static inline void atomic_dec(uint32_t *v)
 {
     asm volatile (
-        "lock ; subl %1,%0"
+        "lock ; decl %0"
         : "=m" (*(volatile uint32_t *)v)
-        : "ir" (i), "m" (*(volatile uint32_t *)v) );
+        : "m" (*(volatile uint32_t *)v) );
 }
+#endif
 
 #ifdef BIDIR_USE_STDMALLOC
 
@@ -811,7 +821,7 @@ int __insert(struct __hash *h, __k_t k, __v_t v)
     TWO_BUCKETS_LOCK_WRUNLOCK(h, bltk, k_idx, bltv, v_idx);
 
     /* Book keeping */
-    atomic_add(&h->nr_ent, 1);
+    atomic_inc(&h->nr_ent);
 
     HASH_LOCK_RDUNLOCK(h);
 
@@ -945,7 +955,7 @@ found_again:
             *pek = e->__prim_next;
             *pev = e->__sec_next;
 
-            atomic_sub(&h->nr_ent, 1);
+            atomic_dec(&h->nr_ent);
             nr_ent = h->nr_ent;
             /* read min_load still under the hash lock! */
             min_load = h->min_load;
@@ -1094,7 +1104,7 @@ found_again:
             *pek = e->__prim_next;
             *pev = e->__sec_next;
 
-            atomic_sub(&h->nr_ent, 1);
+            atomic_dec(&h->nr_ent);
             nr_ent = h->nr_ent;
             /* read min_load still under the hash lock! */
             min_load = h->min_load;